<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>

<s:layout-render name="/layout_template.jsp" nadpis="vehicle.mainHeading">
    <s:layout-component name="telo">
        <s:useActionBean beanclass="cz.muni.fi.pa165.carpark.rest.client.VehicleActionBean" var="actionBean"/>
        
        <c:if test="${actionBean.wasError}" >
            <h3 style="color:red;">
                <f:message key="vehicle.errorBegin"/>
                <c:out value="${actionBean.errorLicencePlate}"/>          
                <f:message key="vehicle.errorEnd"/>
            </h3>
        </c:if>
        
        <table>
            <tr>
                <td>
                <s:form beanclass="cz.muni.fi.pa165.carpark.rest.client.VehicleActionBean" >
                    <div >
                        <s:label  name="vehicle.getByStatus" style="width : 80px;"/>
                    <span >
                    <s:select name="vehicleStatus" >
                        <s:option value="" label=""><f:message key="vehicle.all"/></s:option>
                        <s:options-enumeration enum="cz.muni.fi.pa165.carpark.VehicleStatus"  />
                    </s:select>
                    <s:submit name="getByStatus"><f:message key="show"/></s:submit>
                    </span>        
                    </div>
                </s:form>
                </td>
                <td>
                <s:form beanclass="cz.muni.fi.pa165.carpark.rest.client.VehicleActionBean">
                    <div >
                    <s:label  name="vehicle.getByPosition" style="width : 80px;"/>
                    <span >
                    <s:select name="employeePosition" >
                         <s:option value=""><f:message key="employee.all"/></s:option>
                         <s:options-enumeration enum="cz.muni.fi.pa165.carpark.EmployeePosition"/>
                    </s:select>
                    <s:submit name="getByPosition"><f:message key="show"/></s:submit>
                    </span>        
                    </div>
                </s:form>
                </td>
        </tr>
        </table>
       
            
        <table id="basicview">
            <thead>
                <tr>
                    <th><f:message key="id"/></th>
                    <th><f:message key="vehicle.licencePlate"/></th>
                    <th><f:message key="vehicle.description"/></th>                    
                    <th><f:message key="vehicle.status"/></th>
                    <th/>
                    <th/>
                    <th/>
                </tr>
            </thead>            
            <tbody>
                <c:forEach items="${actionBean.vehicles}" var="vehicle">
                    <tr>                 
                        <td>${vehicle.id}</td>
                        <td><c:out value="${vehicle.stateLicencePlate}"/></td>
                        <td><c:out value="${vehicle.carProducer} ${vehicle.carModel} ${vehicle.engineType}"/></td>  
                        <td><f:message key="VehicleStatus.${vehicle.status}" /></td>
                        <td><s:link class="button" beanclass="cz.muni.fi.pa165.carpark.rest.client.VehicleActionBean" event="delete"><s:param name="vehicle.id" value="${vehicle.id}"/><f:message key="delete"/></s:link> </td>
                        <td><s:link class="button" beanclass="cz.muni.fi.pa165.carpark.rest.client.VehicleActionBean" event="edit"><s:param name="vehicle.id" value="${vehicle.id}"/><f:message key="edit"/></s:link> </td>
                        <td><s:link class="button" beanclass="cz.muni.fi.pa165.carpark.rest.client.VehicleActionBean" event="details"><s:param name="vehicle.id" value="${vehicle.id}"/><f:message key="showDetails"/></s:link> </td>

                    </tr>
                </c:forEach>
            </tbody>            
        </table>    
                    <br>
        <s:link class="button" beanclass="cz.muni.fi.pa165.carpark.rest.client.VehicleActionBean" event="add"><f:message key="vehicle.createNew"/></s:link>
    </s:layout-component>

</s:layout-render>
